/**
 * Created by kux on 2017/7/7.
 */

window.onload=function () {
    //生成9宫格canvas
    for(var i=0;i<9;i++){
       drawBeauty('cv'+i,'pic'+i,3.4,1.56)
    }
    
}

$(function () {
    var U={
        up:$('#upimg img'),
        down:$('#down img'),

    };
    //点击大图片小图修改src
    U.up.click(function () {
        var src=$(this).attr('src');
        var dataid=$(this).attr('data-id');
        U.down.attr('src',src);
        U.down.attr('data-id',dataid);
    });
    //点击小图片大图修改class;
    U.down.click(function () {
        var classname=$(this).attr('class');
        var src=$(this).attr('src')
        //点击小图对应canvas
        var dataid=$(this).attr('data-id');  //data-id值对应一个索引
        // console.log($('#nine canvas').length)
        var dataclass=$(this).attr('data-class');
        //恢复默认样子
        drawBeauty('cv'+dataid,'pic'+dataid,3.4,1.56);   //将与之对应的Canvans重置一下
        adjustColor('cv'+dataid,dataclass);  //传入这个canvas的ID

        console.log(classname);
        console.log(src);
        console.log(dataclass);
        $('#upimg').find('img[src="'+src+'"]').removeAttr('class').addClass(classname);
    });
    $('#ok').click(function () {
        // $('#nine').hide();
        takeScreenshot('nine');
    })


})